package com.ruoyi.web.controller.inspection;
import com.ruoyi.system.entity.InspectionPlanTaskDetailsFile;
import com.ruoyi.system.service.InspectionPlanTaskDetailsFileService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * 计划任务详情表_附件ID(InspectionPlanTaskDetailsFile)表控制层
 * @since 2023-04-17 15:04:53
 */
@RestController
@RequestMapping("inspectionPlanTaskDetailsFile")
public class InspectionPlanTaskDetailsFileController {
    /**
     * 服务对象
     */
    @Resource
    private InspectionPlanTaskDetailsFileService inspectionPlanTaskDetailsFileService;

    /**
     * 分页查询
     * @param inspectionPlanTaskDetailsFile 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @GetMapping
    public ResponseEntity<Page<InspectionPlanTaskDetailsFile>> queryByPage(InspectionPlanTaskDetailsFile inspectionPlanTaskDetailsFile, PageRequest pageRequest) {
        return ResponseEntity.ok(this.inspectionPlanTaskDetailsFileService.queryByPage(inspectionPlanTaskDetailsFile, pageRequest));
    }

    /**
     * 通过主键查询单条数据
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<InspectionPlanTaskDetailsFile> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.inspectionPlanTaskDetailsFileService.queryById(id));
    }

    /**
     * 新增数据
     * @param inspectionPlanTaskDetailsFile 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<InspectionPlanTaskDetailsFile> add(InspectionPlanTaskDetailsFile inspectionPlanTaskDetailsFile) {
        return ResponseEntity.ok(this.inspectionPlanTaskDetailsFileService.insert(inspectionPlanTaskDetailsFile));
    }

    /**
     * 编辑数据
     * @param inspectionPlanTaskDetailsFile 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<InspectionPlanTaskDetailsFile> edit(InspectionPlanTaskDetailsFile inspectionPlanTaskDetailsFile) {
        return ResponseEntity.ok(this.inspectionPlanTaskDetailsFileService.update(inspectionPlanTaskDetailsFile));
    }

    /**
     * 删除数据
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.inspectionPlanTaskDetailsFileService.deleteById(id));
    }

}

